package com.feng.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.feng.pojo.Course;
import com.feng.pojo.User;
import com.feng.service.course.CourseService;
import com.feng.service.course.CourseServiceImpl;

@WebServlet("/already")
public class AlreadyServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 
		User user = (User)req.getSession().getAttribute("USER");
		CourseService courseService = new CourseServiceImpl();
		List<Course> course = courseService.queryElective(user.getUsername());
		
		req.setAttribute("realname", user.getRealname());
		req.setAttribute("list", course);
		
		req.getRequestDispatcher("jsp/studentElective.jsp").forward(req, resp);
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		doGet(req, resp);
	}

}
